﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Data;
using System.Data.SqlClient;
using CMP.ERP.Admin.ServiceReference1;

namespace CMP.ERP.Admin.Controllers
{
    public class ProviderController : Controller
    {
        //
        // GET: /Provider/
        ServiceReference1.Service1Client client = new Service1Client();  //实例化代理类
        /// <summary>
        /// 显示快递公司信息
        /// </summary>
        /// <returns></returns>
        public ActionResult Provider_show()
        {
            List<ServiceReference1.DHLUPSFEDEXEMSInfo> dh = new List<DHLUPSFEDEXEMSInfo>();
            dh = client.GetDHLUPSFEDEXEMSInfo().ToList();//接受XML转化尾List
            return View(dh);
        }
        /// <summary>
        /// 添加快递公司信息
        /// </summary>
        /// <param name="dh"></param>
        /// <returns></returns>
        public ActionResult AddDHLUPSFEDEXEMSInfo(DHLUPSFEDEXEMSInfo dh)
        {
            if (client.AddDHLUPSFEDEXEMSInfo(dh) > 0)
            {
                return Content("<script>alert('添加成功'); location.href='/Provider/Provider_show'</script>");
            }
            else
            {
                return Content("<script>alert('添加失败'); location.href='/Provider/Provider_show'</script>");
            }
        }
        /// <summary>
        /// 删除快递公司信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult DelDHLUPSFEDEXEMSInfo(int id)
        {
            if (client.DelDHLUPSFEDEXEMSInfo(id) > 0)
            {
                return Content("<script>alert('删除成功'); location.href='/Provider/Provider_show'</script>");
            }
            else
            {
                return Content("<script>alert('删除失败'); location.href='/Provider/Provider_show'</script>");
            }
        }
        /// <summary>
        /// 修改的视图
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult UptDHLUPSFEDEXEMSInfo(int id)
        {
            return View(client.getDHLUPSFEDEXEMSInfoByid(id));
        }
        /// <summary>
        /// 修改快递表信息
        /// </summary>
        /// <param name="d"></param>
        /// <returns></returns>
        public ActionResult UptDHLUPSFEDEXEMSInfoDo(DHLUPSFEDEXEMSInfo d)
        {
            if (client.UptDHLUPSFEDEXEMSInfo(d) > 0)
            {
                return Content("<script>alert('修改成功'); location.href='/Provider/Provider_show'</script>");
            }
            else
            {
                return Content("<script>alert('修改失败'); location.href='/Provider/Provider_show'</script>");
            }
        }
        /// <summary>
        /// 根据姓名搜索快递表信息
        /// </summary>
        /// <param name="DHLUPSFEDEXEMSName"></param>
        /// <returns></returns>
        public ActionResult SearchDHLUPSFEDEXEMSInfo(string DHLUPSFEDEXEMSName)
        {
            List<ServiceReference1.DHLUPSFEDEXEMSInfo> dh = new List<DHLUPSFEDEXEMSInfo>();
            dh = client.SearchDHLUPSFEDEXEMSInfo(DHLUPSFEDEXEMSName).ToList();//接受XML转化尾List
            return View("Provider_show", dh);
        }
    }
}
